package com.txw.javaCore.server.mq;

import com.txw.javaCore.model.entity.LoginEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * @PROJECT_NAME: JavaCoreB2
 * @DESCRIPTION: Spring的事件驱动模型，消费者
 * @Author: 涂玄武
 * @DATE: 2021/1/19 10:01
 */
@Component
@EnableAsync
public class LoginConsumer implements ApplicationListener<LoginEvent> {

    private static final Logger log = LoggerFactory.getLogger(LoginConsumer.class);

    /**
     * 监听消费消息
     * @param event
     */
    @Override
    @Async
    public void onApplicationEvent(LoginEvent event) {
        log.info("Spring 事件驱动模型 - 接收消息：{}",event);

        //TODO:后续为实现自身的业务逻辑，如写入数据库等
    }
}
